package br.com.vti.sisp_sicrim.antigo.controller.relatorios;

import java.io.FileNotFoundException;
import java.text.ParseException;

import net.sf.jasperreports.engine.JRException;
import br.com.caelum.vraptor.Result;
import br.com.vti.sisp_sicrim.antigo.util.Relatorios;
import br.com.vti.sisp_sicrim.antigo.util.Sessao;

/**
 * Classe responsavel por encapsular o tratamento e as consistencias da tela
 * Idcsut01Report
 * 
 * @author Incode - Data: jun/2014
 * 
 */
public class Idcsut01Report {
	private long regger;
	private int datn;
	private String nom1;
	private String nom2;
	private String f1;
	private String f2;
	private String f3;
	private String comun;
	private int datnas;
	private String docum1;
	private String docum2;
	private String pis;
	private String numcpf;
	private long pispas;
	private Integer numpos;
	private String numvia;
	private Result result;
	private Sessao sessao;
	private Relatorios report; // Classes views

	// Classes includes
	public Idcsut01Report() throws JRException {
		inicializar();
	}

	public Idcsut01Report(Sessao sessao) throws JRException {
		this.sessao = sessao;
		inicializar();
	}

	public void inicializar() throws JRException {
		report = new Relatorios();
		regger = 0;
		datn = 0;
		nom1 = "";
		nom2 = "";
		f1 = "";
		f2 = "";
		f3 = "";
		comun = "";
		datnas = 0;
		docum1 = "";
		docum2 = "";
		pis = "";
		numcpf = "";
		pispas = 0;
		numpos = 0;
		numvia = "";
		report.setNumeroRel(1, "D");
		{
			report.setNumeroLinhaRel(2, 2);
			{
				report.adicionaCampo(8, 13, "Regger", "N", "ZZZ999999999-9", "");
				report.adicionaCampo(28, 8, "Datn", "N", "99/99/9999", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(3, 1);
			{
				report.adicionaCampo(3, 35, "Nom1", "X", "", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(4, 1);
			{
				report.adicionaCampo(3, 35, "Nom2", "X", "", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(6, 1);
			{
				report.adicionaCampo(3, 35, "F1", "X", "", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(7, 1);
			{
				report.adicionaCampo(3, 35, "F2", "X", "", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(8, 1);
			{
				report.adicionaCampo(3, 35, "F3", "X", "", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(9, 2);
			{
				report.adicionaCampo(3, 24, "Comun", "X", "", "");
				report.adicionaCampo(28, 8, "Datnas", "N", "99/99/9999", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(11, 1);
			{
				report.adicionaCampo(3, 35, "Docum1", "X", "", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(12, 2);
			{
				report.adicionaCampo(3, 20, "Docum2", "X", "", "");
				report.adicionaCampo(29, 9, "Pis", "X", "", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(13, 2);
			{
				report.adicionaCampo(3, 11, "Numcpf", "X", "XXXXXXXXXX-XX", "");
				report.adicionaCampo(25, 13, "Pispas", "N", "ZZZZZZZZZZZZZ", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(14, 2);
			{
				report.adicionaCampo(3, 5, "Numpos", "X", "", "");
				report.adicionaCampo(32, 6, "Numvia", "X", "", "");
				report.setFimLinhaRel();
			}
			report.setNumeroLinhaRel(18, 1);
			{
				report.adicionaCampo(1, 1, "lit_1_1", "C", "", ".");
				report.setFimLinhaRel();
			}
		}
	}

	public boolean validar() {
		// validar os campos recebidos da tela
		return true;
	}

	public long getRegger() {
		return regger;
	}

	public void setRegger(long regger) throws ParseException {
		this.regger = regger;
		report.adicionaValorReport("Regger", regger);
	}

	public int getDatn() {
		return datn;
	}

	public void setDatn(int datn) throws ParseException {
		this.datn = datn;
		report.adicionaValorReport("Datn", datn);
	}

	public String getNom1() {
		return nom1;
	}

	public void setNom1(String nom1) throws ParseException {
		this.nom1 = nom1;
		report.adicionaValorReport("Nom1", nom1);
	}

	public String getNom2() {
		return nom2;
	}

	public void setNom2(String nom2) throws ParseException {
		this.nom2 = nom2;
		report.adicionaValorReport("Nom2", nom2);
	}

	public String getF1() {
		return f1;
	}

	public void setF1(String f1) throws ParseException {
		this.f1 = f1;
		report.adicionaValorReport("F1", f1);
	}

	public String getF2() {
		return f2;
	}

	public void setF2(String f2) throws ParseException {
		this.f2 = f2;
		report.adicionaValorReport("F2", f2);
	}

	public String getF3() {
		return f3;
	}

	public void setF3(String f3) throws ParseException {
		this.f3 = f3;
		report.adicionaValorReport("F3", f3);
	}

	public String getComun() {
		return comun;
	}

	public void setComun(String comun) throws ParseException {
		this.comun = comun;
		report.adicionaValorReport("Comun", comun);
	}

	public int getDatnas() {
		return datnas;
	}

	public void setDatnas(int datnas) throws ParseException {
		this.datnas = datnas;
		report.adicionaValorReport("Datnas", datnas);
	}

	public String getDocum1() {
		return docum1;
	}

	public void setDocum1(String docum1) throws ParseException {
		this.docum1 = docum1;
		report.adicionaValorReport("Docum1", docum1);
	}

	public String getDocum2() {
		return docum2;
	}

	public void setDocum2(String docum2) throws ParseException {
		this.docum2 = docum2;
		report.adicionaValorReport("Docum2", docum2);
	}

	public String getPis() {
		return pis;
	}

	public void setPis(String pis) throws ParseException {
		this.pis = pis;
		report.adicionaValorReport("Pis", pis);
	}

	public String getNumcpf() {
		return numcpf;
	}

	public void setNumcpf(String numcpf) throws ParseException {
		this.numcpf = numcpf;
		report.adicionaValorReport("Numcpf", numcpf);
	}

	public long getPispas() {
		return pispas;
	}

	public void setPispas(long pispas) throws ParseException {
		this.pispas = pispas;
		report.adicionaValorReport("Pispas", pispas);
	}

	public int getNumpos() {
		return numpos;
	}

	public void setNumpos(int numpos) throws ParseException {
		this.numpos = numpos;
		report.adicionaValorReport("Numpos", numpos);
	}

	public String getNumvia() {
		return numvia;
	}

	public void setNumvia(String numvia) throws ParseException {
		this.numvia = numvia;
		report.adicionaValorReport("Numvia", numvia);
	}

	public void setPageSize(int pagesize) throws JRException {
		report.setPageSize(pagesize);
	}

	public void setLineSize(int linesize) {
		report.setLineSize(linesize);
	}

	public int getPageSize() {
		return report.getPageSize();
	}

	public int getPageLine() {
		return report.getPageLine();
	}

	public void saltaLinhas(int qtdLinhas) throws ParseException, JRException {
		report.saltaLinhas(qtdLinhas);
	}

	public void gravaRelatorio(int nroRel) throws ParseException, JRException {
		report.gravaRelatorio(report, nroRel, false);
	}

	public void imprimir() throws FileNotFoundException, JRException {
		report.imprimir();
	}
}
